package ua.org.nuos.sdms.clientgui.client.components.factory;

import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

/**
 * Created by IntelliJ IDEA.
 * User: dio
 * Date: 19.02.12
 * Time: 20:46
 * To change this template use File | Settings | File Templates.
 */
public class WindowFactory {

    public static Window getModalWindow(String width, String title) {
        Window window = new Window(title);
        window.setModal(true);
        window.setWidth(width);
        window.setResizable(false);
        window.setImmediate(true);
        VerticalLayout layout = (VerticalLayout) window.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        return window;
    }

    public static Window getModalWindow(String width, String height, String title) {
        Window window = getModalWindow(width, title);
        window.setHeight(height);
        return window;
    }

    public static Button getCloseButton(final Window window, String title) {
        return ButtonFactory.getButton(title, new Button.ClickListener() {
            public void buttonClick(Button.ClickEvent event) {
                (window.getParent()).removeWindow(window);
            }
        });
    }
}
